home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Utilities / QuickTime VCR 3.5 / MP Source / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-17  |  17.3 KB  |  807 lines  |  [TEXT/KAHL]

  1. /*---------------------------------------------------------------------
  2.     File: main.c
  3.     Purpose: 
  4.     
  5.     Created by: Geoffrey Slinker
  6.     Date: 8:26:41 AM  6/8/92
  7.     Modified: 
  8. ---------------------------------------------------------------------*/
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <oops.h>
  12. #include <Movies.h>
  13.  
  14. #include "Dlog.h"
  15. #include "about_Dlog.h"
  16. #include "Alert_Class.h"
  17. #include "vcr.h"
  18. #include "mycolors.h"
  19. #include "myQuickTime.h"
  20.  
  21. #define NUKE_ALL_EVENTS    0
  22. #define NULL_POINTER NULL
  23.  
  24. #define MY_ALERT    601
  25. //#define VCR_DLOG    700
  26. #define VCR_DLOG    702
  27.  
  28.  
  29. #define BASE_MENU    600
  30. #define APPLE_ID    600
  31. #define FILE_ID        601
  32. #define VCR_ID        603
  33. #define WINDOW_ID    604
  34.  
  35. #define ABOUT_ITEM    1
  36.  
  37.  
  38. #define OPEN_ITEM    1
  39. #define CLOSE_ITEM    2
  40. #define    QUIT_ITEM    4
  41.  
  42. #define PLAY_ITEM    1
  43. #define FF_ITEM        3
  44. #define REW_ITEM    4
  45. #define GO_END_ITEM    5
  46. #define GO_START_ITEM    6
  47. #define STOP_ITEM    8
  48. #define V_UP_ITEM    10
  49. #define V_DOWN_ITEM 11
  50.  
  51.  
  52. #define SHOW_VCR_ITEM 1
  53. #define SHOW_POSTER_ITEM    2
  54. /*-------------------------
  55. protos
  56. -------------------------*/
  57. void InitMac(void);
  58. void MainLoop(void);
  59. int Eventful(void);
  60. int HandleMouseDown(void);
  61. int HandleMenuChoice (long int choice);
  62. void HandleAppleChoice(int theItem);
  63. int HandleFileChoice(int theItem);
  64. int HandleVCRChoice(int theItem);
  65. int HandleWindowChoice(int theItem);
  66.  
  67. void MenuBarInit(void);
  68. void InitMyStuff(void);
  69. void CleanUpMyStuff(void);
  70. void ClockTask(void);
  71. void MaintainMenus(void);
  72.  
  73. /*-------------------------
  74. globals
  75. -------------------------*/
  76. EventRecord gEvent;
  77. MenuHandle gAppleMenu;
  78. about_Dlog *aboutDlog;
  79. Alert_Class *myAlert;
  80. QT *myQT;
  81. Boolean moviesLoaded = false;
  82. VCR *vcr;
  83. Boolean opened = false;
  84.  
  85. //DateTimeRec oldT;
  86. long oldClockTick; // used for updating vcr clock
  87. extern Boolean blink;
  88. extern long oldTick; // used for updating status
  89.  
  90. /**********************************************************************/
  91. void main()
  92. {
  93.     InitMac();
  94.     
  95.     MainLoop();
  96.     
  97.     CleanUpMyStuff();
  98. }
  99. /*---------------------------------------------------------------------
  100.     Function: InitMac()
  101.     Purpose: 
  102.     Returns: 
  103.     
  104.     Created by: Geoffrey Slinker
  105.     Date: 8:30:00 AM  6/8/92
  106.     Modified: 
  107. ---------------------------------------------------------------------*/
  108. void InitMac()
  109. {
  110.     SysEnvRec thisMac;
  111.     
  112.     InitGraf(&thePort);
  113.     InitFonts();
  114.     FlushEvents(everyEvent,NUKE_ALL_EVENTS);
  115.     InitWindows();  // This calls InitPalettes
  116.     InitMenus();
  117.     TEInit();
  118.     InitDialogs(NULL_POINTER);
  119.     InitCursor();
  120.     MaxApplZone();
  121.     
  122.     MenuBarInit();
  123.     
  124.     // Is Color QuickDraw available?
  125.     SysEnvirons(1,&thisMac);
  126.     if ( !thisMac.hasColorQD ) {
  127.         
  128.         ParamText("\pColor QuickDraw is needed","\pPlease install Color QuickDraw",
  129.         "\p","\p");    
  130.         StopAlert(602,(ProcPtr)NULL);
  131.         ExitToShell();
  132.  
  133.     }
  134.     
  135.     InitMyStuff();
  136.  
  137.     /*-------------------------
  138.     Other things related to the MAC
  139.     or the MAC interface that needs
  140.     to be initiated
  141.     -------------------------*/
  142.     
  143.     (*myQT).MovieCheck();  // Is QuickTime available?
  144.     moviesLoaded = true;
  145.     
  146.     
  147. }
  148. /*---------------------------------------------------------------------
  149.     Function: void MainLoop()
  150.     Purpose: repeatedly call function with getnext event and very
  151.     large switch statement.
  152.     Returns: 
  153.     
  154.     Created by: Geoffrey Slinker
  155.     Date: 8:33:44 AM  6/8/92
  156.     Modified: 
  157.     
  158.     
  159.     
  160.     theErr := FSMakeFSSpec(theSFReply.vRefNum, 0, theSFReply.fName, mySpec);
  161.     
  162. ---------------------------------------------------------------------*/
  163. void MainLoop()
  164. {
  165.     AppFile theFile;
  166.     int message, count;
  167.     int response = 1;
  168.     FSSpec mySpec;
  169.     /*-------------------------
  170.     Did they drag and drop?
  171.     -------------------------*/
  172.     
  173.     CountAppFiles(&message,&count);
  174.     if ( (message == 0) && (count >= 1)  ) {
  175.         char stuff[80];
  176.         
  177.         GetAppFiles(1,&theFile);
  178.         //(*myAlert).AlertNote("\pDrag and Drop ocurred",theFile.fName,"\p","\p");
  179.         if ( FSMakeFSSpec(theFile.vRefNum, 0, theFile.fName, &mySpec) != noErr ) {
  180.             (*myAlert).AlertCaution("\pUnable to open from drag and drop",
  181.                 "\p","\p","\p");
  182.         } else {
  183.             opened = (*myQT).OpenMovieFSSpec(mySpec);
  184.         }
  185.         ClrAppFiles(1);
  186.     } /* end if */
  187.     
  188.  
  189.     while (response == 1){
  190.         response = Eventful();
  191.     }
  192.     
  193. }
  194. /*---------------------------------------------------------------------
  195.     Function: Eventful()
  196.     Purpose: Contains GetNextEvent and the switch statement.
  197.     Returns: 
  198.     
  199.     Created by: Geoffrey Slinker
  200.     Date: 8:35:17 AM  6/8/92
  201.     Modified: 
  202.     
  203. ---------------------------------------------------------------------*/
  204. int Eventful()
  205. {
  206.     int response = 1;
  207.     char theChar;
  208.     GrafPtr aPort;
  209.     WindowPtr whichWindow;
  210.     Movie myMovie;
  211.     CWindowPtr movieWindow,moviePosterWindow;
  212.     DialogPtr myDlog = (*vcr).myDlog;
  213.     Boolean isDaWindow;
  214.                     
  215.     
  216.     
  217.     myMovie = (*myQT).myMovie;
  218.     movieWindow = (*myQT).movieWindow;
  219.     moviePosterWindow = (*myQT).moviePosterWindow;
  220.     
  221.     SystemTask();
  222.     ClockTask();
  223.     (*myQT).MyMoviesTask();
  224.     MaintainMenus();
  225.     
  226.     
  227.     GetNextEvent(everyEvent,&gEvent);
  228.     
  229.     switch ( gEvent.what  ) {
  230.         case mouseDown:
  231.             response = HandleMouseDown();
  232.             break;
  233.         
  234.         case keyDown:
  235.         case autoKey:
  236.             theChar = gEvent.message & charCodeMask;
  237.             if ( (gEvent.modifiers & cmdKey) != 0  ) {
  238.                 response = HandleMenuChoice( MenuKey(theChar));
  239.             }
  240.             else {
  241.                 whichWindow = FrontWindow();
  242.             }
  243.             break;
  244.         
  245.         case activateEvt:
  246.             SetPort( (WindowPtr) gEvent.message );
  247.             InvalRect(&((WindowPtr)gEvent.message)->portRect);
  248.             break;
  249.             
  250.         case updateEvt:            
  251.             whichWindow = (WindowPtr)gEvent.message;
  252.             if ( whichWindow == NULL_POINTER  ) {
  253.                 isDaWindow = false;
  254.                 break;
  255.             }
  256.             else {
  257.                 isDaWindow = (( (WindowPeek)whichWindow)->windowKind < 0);
  258.             } /* end if then else */
  259.             
  260.             if ( !isDaWindow ) 
  261.             {
  262.                 BeginUpdate((WindowPtr)gEvent.message);
  263.  
  264.                 GetPort(&aPort);
  265.                 SetPort((WindowPtr)gEvent.message);
  266.  
  267.                     if ( (WindowPtr)gEvent.message == myDlog) {
  268.                         (*vcr).RedrawDialog();
  269.                     }
  270.                     
  271.                     if ((CWindowPtr)gEvent.message == movieWindow) {
  272.                         if ( (opened) && (myMovie != NULL)){
  273.                             UpdateMovie( myMovie );
  274.                         }
  275.                     }
  276.                     
  277.                     if ((CWindowPtr)gEvent.message == moviePosterWindow) {
  278.                         if ( (opened) && (myMovie != NULL)){
  279.                             (*myQT).RedrawPoster();
  280.                         }
  281.                     }
  282.                     
  283.                 EndUpdate((WindowPtr)gEvent.message);
  284.  
  285.                 SetPort(aPort);
  286.             } /* end if */
  287.  
  288.             break;
  289.             
  290.         case nullEvent:
  291.             break;
  292.                 
  293.         default: 
  294.             response = 1;
  295.             break;
  296.             
  297.     } /* end switch */
  298.  
  299.  
  300.     return(response);
  301. }
  302. /*---------------------------------------------------------------------
  303.     Function: HandleMouseDown
  304.     Purpose: 
  305.     Returns: 
  306.     
  307.     Created by: Geoffrey Slinker
  308.     Date: 8:38:43 AM  6/8/92
  309.     Modified: 
  310. ---------------------------------------------------------------------*/
  311. int HandleMouseDown()
  312. {    
  313.     WindowPtr whichWindow,frontWindow;
  314.     short int thePart;
  315.     long int menuChoice, windSize;
  316.     Rect bRect;
  317.     int response = 1;
  318.     Point thePoint;
  319.     
  320.     thePart = FindWindow(gEvent.where,&whichWindow);
  321.     
  322.     switch ( thePart  ) {
  323.         case inMenuBar:
  324.             menuChoice = MenuSelect(gEvent.where);
  325.             response = HandleMenuChoice(menuChoice);
  326.             break;
  327.         
  328.         case inSysWindow:
  329.             SystemClick(&gEvent,whichWindow);
  330.             break;
  331.         
  332.         case inDrag:
  333.             SelectWindow(whichWindow);
  334.             bRect = screenBits.bounds;
  335.             DragWindow(whichWindow,gEvent.where, &bRect);    
  336.             break;
  337.             
  338.         case inContent:
  339.             frontWindow = FrontWindow();
  340.             SelectWindow(whichWindow);
  341.             SetPort(whichWindow);
  342.             if (whichWindow == (*vcr).myDlog) {
  343.                 (*vcr).HandleDialog(&gEvent);
  344.             }
  345.             break;
  346.             
  347.         case inGoAway:
  348.             HideWindow(whichWindow);
  349.             break;    
  350.         default: response = 1; break;
  351.     } /* end switch */
  352.     
  353.     return(response);
  354. }
  355. /*---------------------------------------------------------------------
  356.     Function: int HandleMenuChoice(long int choice)
  357.     Purpose: Distribute the menu choice to the proper handler.
  358.     Returns: 
  359.     
  360.     Created by: Geoffrey Slinker
  361.     Date: 8:41:11 AM  6/8/92
  362.     Modified: 
  363. ---------------------------------------------------------------------*/
  364. int HandleMenuChoice (long int choice)
  365. {
  366.     int theMenu;
  367.     int    theItem;
  368.     int response;
  369.     char stuff[80];
  370.     Str255 message;
  371.     
  372.     response = 1;
  373.     
  374.     if (choice != 0) {
  375.         theMenu = HiWord(choice);
  376.         theItem = LoWord(choice);
  377.         
  378.         switch ( theMenu  ) {
  379.             case APPLE_ID:
  380.                 HandleAppleChoice(theItem);
  381.                 break;
  382.             
  383.             case FILE_ID: 
  384.                 response = HandleFileChoice(theItem);
  385.                 break;
  386.             case VCR_ID:
  387.                 HandleVCRChoice(theItem);
  388.                 break;
  389.             case WINDOW_ID:
  390.                 response = HandleWindowChoice(theItem);
  391.                 break;
  392.                     
  393.             default: 
  394.                 sprintf((char *)message,"Menu Bar Item = %d",theItem);
  395.                 (*myAlert).AlertCaution("\pUnimplemented Menu Bar Item",
  396.                                         CtoPstr(message),"\pSorry!",NULL);
  397.                 break;
  398.         } /* end switch */
  399.     } /* end if */
  400.     
  401.     HiliteMenu(0);
  402.     return(response);
  403. }
  404. /*---------------------------------------------------------------------
  405.     Function: HandleAppleChoice
  406.     Purpose: 
  407.     Returns: 
  408.     
  409.     Created by: Geoffrey Slinker
  410.     Date: 8:42:38 AM  6/8/92
  411.     Modified: 
  412. ---------------------------------------------------------------------*/
  413. void HandleAppleChoice(int theItem)
  414. {
  415.     Str255    accName;
  416.     int        accNumber;
  417.     
  418.     switch ( theItem  ) {
  419.         case ABOUT_ITEM:
  420.             (*aboutDlog).HandleDialog(&gEvent);
  421.             break;
  422.         default:
  423.             GetItem(gAppleMenu,theItem,accName);
  424.             accNumber = OpenDeskAcc(accName);
  425.             break;
  426.     } /* end switch */
  427. }
  428. /*---------------------------------------------------------------------
  429.     Function: HandleFileChoice
  430.     Purpose: 
  431.     Returns: 
  432.     
  433.     Created by: Geoffrey Slinker
  434.     Date: 8:44:06 AM  6/8/92
  435.     Modified: 
  436. ---------------------------------------------------------------------*/
  437. int HandleFileChoice(int theItem)
  438. {
  439.     int response;
  440.     WindowPtr whichWindow;
  441.     Str255 message;
  442.     
  443.     response = 1;
  444.     
  445.     switch ( theItem  ) {
  446.         case OPEN_ITEM: 
  447.             opened = (*myQT).OpenMovie();
  448.             break;
  449.             
  450.         case CLOSE_ITEM:
  451.             (*myQT).CloseMovie();
  452.             opened = false;
  453.             break;
  454.             
  455.         case QUIT_ITEM:    response = 0; break;
  456.         default: 
  457.             sprintf((char *)message,"Menu Bar Item = %d",theItem);
  458.                 (*myAlert).AlertCaution("\pUnimplemented Menu Bar Item",
  459.                                         CtoPstr(message),"\pSorry!",NULL);
  460.             break;
  461.     } /* end switch */
  462.     
  463.     return(response);
  464. }
  465. /*---------------------------------------------------------------------
  466. #define PLAY_ITEM    1
  467. #define FF_ITEM        3
  468. #define REW_ITEM    4
  469. #define GO_END_ITEM    5
  470. #define GO_START_ITEM    6
  471. #define STOP_ITEM    8
  472.     Function: HandleVCRChoice
  473.     Purpose: 
  474.     Returns: 
  475.     
  476.     Created by: Geoffrey Slinker
  477.     Date: 4:29:34 PM  8/1/92
  478.     Modified: 
  479. ---------------------------------------------------------------------*/
  480. int HandleVCRChoice(int theItem)
  481. {
  482.     int response;
  483.     WindowPtr whichWindow;
  484.     Str255 message;
  485.     Buttons myButtons;
  486.     DialogPtr myDlog = (*vcr).myDlog;
  487.     GrafPtr oldPort;
  488.     
  489.     GetPort(&oldPort);
  490.     SetPort(myDlog);
  491.     response = 1;
  492.     myButtons = (*vcr).myButtons;
  493.     
  494.     switch ( theItem  ) {
  495.         case PLAY_ITEM: 
  496.             if (myButtons.button[PLAY_BUTTON] == false) {
  497.                 (*vcr).ButtonsAndValues(PLAY_BUTTON);
  498.                 (*vcr).vcr_mode = playing;
  499.                 (*myQT).PlayMovie();
  500.             }
  501.             break;
  502.             
  503.         case FF_ITEM:
  504.             if (myButtons.button[FF_BUTTON] == false) {
  505.                 (*vcr).vcr_mode = fastforward;
  506.                 (*vcr).ButtonsAndValues(FF_BUTTON);
  507.                 (*myQT).FFMyMovie();
  508.             }
  509.             break;
  510.             
  511.         case REW_ITEM:
  512.             if (myButtons.button[RW_BUTTON] == false) {
  513.                 (*vcr).vcr_mode = re_wind;
  514.                 (*vcr).ButtonsAndValues(RW_BUTTON); 
  515.                 (*myQT).RWMyMovie();
  516.             }
  517.             break;
  518.             
  519.         case GO_END_ITEM: 
  520.             if (myButtons.button[GO_END_BUTTON] == false) {
  521.                 (*vcr).vcr_mode = gotoend;
  522.                 (*vcr).ButtonsAndValues(GO_END_BUTTON);
  523.                 myButtons = (*vcr).myButtons;
  524.                 myButtons.button[GO_END_BUTTON] = false;
  525.                 (*vcr).myButtons = myButtons;
  526.                 (*vcr).RedrawButtons();
  527.                 (*myQT).GoEndMyMovie();
  528.             }
  529.             break;
  530.             
  531.         case GO_START_ITEM: 
  532.             if (myButtons.button[GO_START_BUTTON] == false) {
  533.                 (*vcr).vcr_mode = gotostart;
  534.                 (*vcr).ButtonsAndValues(GO_START_BUTTON);
  535.                 myButtons = (*vcr).myButtons;
  536.                 myButtons.button[GO_START_BUTTON] = false;
  537.                 (*vcr).myButtons = myButtons;
  538.                 (*vcr).RedrawButtons();
  539.                 (*myQT).GoStartMyMovie();
  540.             }
  541.             break;
  542.             
  543.         case STOP_ITEM: 
  544.             if (myButtons.button[STOP_BUTTON] == false) {
  545.                 (*vcr).vcr_mode = stopped;
  546.                 (*vcr).ButtonsAndValues(STOP_BUTTON);
  547.                 myButtons = (*vcr).myButtons;
  548.                 myButtons.button[STOP_BUTTON] = false;
  549.                 (*vcr).myButtons = myButtons;
  550.                 (*vcr).RedrawButtons();
  551.                 (*vcr).DrawAllProgress(sl_darkGray);
  552.                 (*myQT).StopMyMovie();
  553.             }
  554.             break;
  555.         
  556.         case V_UP_ITEM:
  557.             (*myQT).HandleVolume(UP);
  558.             (*vcr).FlashButton(VOLUME_UP);
  559.             break;
  560.             
  561.         case V_DOWN_ITEM:
  562.             (*myQT).HandleVolume(DOWN);
  563.             (*vcr).FlashButton(VOLUME_DOWN);
  564.             break;
  565.                         
  566.         default: 
  567.             sprintf((char *)message,"Menu Bar Item = %d",theItem);
  568.                 (*myAlert).AlertCaution("\pUnimplemented Menu Bar Item",
  569.                                         CtoPstr(message),"\pSorry!",NULL);
  570.             break;
  571.     } /* end switch */
  572.     
  573.     SetPort(oldPort);
  574.     return(response);
  575. }
  576. /*---------------------------------------------------------------------
  577.     Function: HandleWindowChoice
  578.     Purpose: 
  579.     Returns: 
  580.     
  581.     Created by: Geoffrey Slinker
  582.     Date: 4:29:34 PM  8/1/92
  583.     Modified: 
  584. ---------------------------------------------------------------------*/
  585. int HandleWindowChoice(int theItem)
  586. {
  587.     int response;
  588.     Str255 message;
  589.     DialogPtr myDlog = (*vcr).myDlog;
  590.     CWindowPtr moviePosterWindow = (*myQT).moviePosterWindow;
  591.  
  592.     response = 1;
  593.     
  594.     switch ( theItem  ) {
  595.         
  596.         
  597.         case SHOW_VCR_ITEM:
  598.             if ( ((WindowPeek)myDlog)->visible ) {
  599.                 HideWindow(myDlog);
  600.             }
  601.             else {
  602.                 ShowWindow(myDlog);
  603.                 SelectWindow( (WindowPtr)myDlog);
  604.             }
  605.         
  606.     
  607.     
  608.             break;
  609.             
  610.         case SHOW_POSTER_ITEM:
  611.             if ( ((CWindowPeek)moviePosterWindow)->visible ) {
  612.                 HideWindow((WindowPtr)moviePosterWindow);
  613.             }
  614.             else {
  615.                 ShowWindow((WindowPtr)moviePosterWindow);
  616.                 SelectWindow((WindowPtr)moviePosterWindow);
  617.             }
  618.             break;
  619.                                             
  620.         default: 
  621.             sprintf((char *)message,"Menu Bar Item = %d",theItem);
  622.                 (*myAlert).AlertCaution("\pUnimplemented Menu Bar Item",
  623.                                         CtoPstr(message),"\pSorry!","\pHandleWindowChoice");
  624.             break;
  625.     } /* end switch */
  626.     
  627.     return(response);
  628. }
  629.  
  630. /*---------------------------------------------------------------------
  631.     Function: void MenuBarInit()
  632.     Purpose: Load the menu resources
  633.     Returns: 
  634.     
  635.     Created by: Geoffrey Slinker
  636.     Date: 9:06:34 AM  6/8/92
  637.     Modified: 
  638. ---------------------------------------------------------------------*/
  639. void MenuBarInit()
  640. {
  641.     Handle myBar;    
  642.  
  643.     if ( (myBar = GetNewMBar(BASE_MENU)) == NULL_POINTER  ) {
  644.         ExitToShell();
  645.     } /* end if */
  646.     
  647.     SetMenuBar(myBar);
  648.     
  649.     if ( (gAppleMenu = GetMHandle( APPLE_ID)) == NULL_POINTER  ) {
  650.         ExitToShell();
  651.     } /* end if */
  652.     
  653.     AddResMenu(gAppleMenu,'DRVR');
  654.     
  655.  
  656.     DrawMenuBar();
  657. }
  658. /*---------------------------------------------------------------------
  659.     Function: InitMyStuff();
  660.     Purpose: 
  661.     Returns: 
  662.     
  663.     Created by: Geoffrey Slinker
  664.     Date: 9:16:28 AM  6/8/92
  665.     Modified: 
  666. ---------------------------------------------------------------------*/
  667. void InitMyStuff()
  668. {
  669.     DialogPtr myDlog;
  670.     
  671.     oldClockTick = oldTick = TickCount();
  672.     aboutDlog = new about_Dlog;
  673.     (*aboutDlog).loadResource(ABOUT_DLOG);
  674.     
  675.     myAlert = new Alert_Class;
  676.     (*myAlert).ChooseResource(MY_ALERT);
  677.     
  678.     vcr = new VCR;
  679.     (*vcr).loadResource(VCR_DLOG);
  680.     (*vcr).PutUpDialog();
  681.     
  682.     myQT = new QT;
  683.     (*myQT).LoadResources(); 
  684. }
  685. /*---------------------------------------------------------------------
  686.     Function: CleanUpMyStuff()
  687.     Purpose: 
  688.     Returns: 
  689.     
  690.     Created by: Geoffrey Slinker
  691.     Date: 9:16:28 AM  6/8/92
  692.     Modified: 
  693. ---------------------------------------------------------------------*/
  694. void CleanUpMyStuff()
  695. {
  696.     delete aboutDlog;
  697.     delete myAlert;
  698.     delete vcr;
  699.     delete myQT;
  700.     
  701.     if (moviesLoaded) {
  702.         ExitMovies();
  703.     }
  704.     
  705. }
  706. /*---------------------------------------------------------------------
  707.     Function: ClockTask();
  708.     Purpose: 
  709.     Returns: 
  710.     
  711.     Created by: Geoffrey Slinker
  712.     Date: 4:22:18 PM  6/12/92
  713.     Modified: 
  714. ---------------------------------------------------------------------*/
  715. void ClockTask()
  716. {
  717.     long newClockTick;
  718.     Boolean blinky;
  719.     DialogPtr myDlog = (*vcr).myDlog;
  720.     
  721.     // IF the vcr is not visible then we don't need
  722.     // to draw anything!
  723.     if ( ((WindowPeek)myDlog)->visible != 1) {
  724.         return;
  725.     }
  726.     
  727.     blinky = blink;
  728.     newClockTick = TickCount();
  729.  
  730.     
  731.     if ( (newClockTick - oldClockTick) >= 60) {
  732.     
  733.         blink = !blink;
  734.         oldClockTick = newClockTick;
  735.     }
  736.     if (blink != blinky) (*vcr).RedrawTime();
  737.     (*vcr).UpdateProgress();
  738. }
  739. /*---------------------------------------------------------------------
  740.     Function: void MaintainMenus()
  741.     Purpose: 
  742.     Returns: 
  743.     
  744.     Created by: Geoffrey Slinker
  745.     Date: 10:49:56 AM  6/13/92
  746.     Modified: 
  747. ---------------------------------------------------------------------*/
  748. void MaintainMenus()
  749. {
  750.     WindowPtr frontWindow;
  751.     MenuHandle theMenu,vcrMenu;
  752.     DialogPtr myDlog;
  753.     CWindowPtr moviePosterWindow;
  754.     
  755.  
  756.     moviePosterWindow = (*myQT).moviePosterWindow;
  757.     myDlog = (*vcr).myDlog;
  758.     
  759.     
  760.     theMenu = GetMHandle(FILE_ID);
  761.     vcrMenu = GetMHandle(VCR_ID);
  762.     
  763.     if (opened) {
  764.         DisableItem(theMenu,OPEN_ITEM);
  765.         EnableItem(theMenu,CLOSE_ITEM);
  766.         EnableItem(vcrMenu,PLAY_ITEM);
  767.         EnableItem(vcrMenu,STOP_ITEM);
  768.         EnableItem(vcrMenu,FF_ITEM);
  769.         EnableItem(vcrMenu,REW_ITEM);
  770.         EnableItem(vcrMenu,GO_START_ITEM);
  771.         EnableItem(vcrMenu,GO_END_ITEM);
  772.         EnableItem(vcrMenu,V_UP_ITEM);
  773.         EnableItem(vcrMenu,V_DOWN_ITEM);
  774.  
  775.     }
  776.     else {
  777.         DisableItem(theMenu,CLOSE_ITEM);
  778.         EnableItem(theMenu,OPEN_ITEM);
  779.         
  780.         DisableItem(theMenu,CLOSE_ITEM);
  781.         DisableItem(vcrMenu,PLAY_ITEM);
  782.         DisableItem(vcrMenu,STOP_ITEM);
  783.         DisableItem(vcrMenu,FF_ITEM);
  784.         DisableItem(vcrMenu,REW_ITEM);
  785.         DisableItem(vcrMenu,GO_START_ITEM);
  786.         DisableItem(vcrMenu,GO_END_ITEM);
  787.         DisableItem(vcrMenu,V_UP_ITEM);
  788.         DisableItem(vcrMenu,V_DOWN_ITEM);
  789.     }
  790.     
  791.     theMenu = GetMHandle(WINDOW_ID);
  792.     if ( ((WindowPeek)myDlog)->visible ) {
  793.         SetItem(theMenu,1,"\pHide VCR");
  794.     }
  795.     else {
  796.         SetItem(theMenu,1,"\pShow VCR");
  797.     }
  798.     
  799.     if ( ((CWindowPeek)moviePosterWindow)->visible ) {
  800.         SetItem(theMenu,2,"\pHide Poster");
  801.     }
  802.     else {
  803.         SetItem(theMenu,2,"\pShow Poster");
  804.     }
  805.     
  806. }
  807.